import request from "@/utils/request.js";
import {useUserStore} from "@/store/index.js";

const userStore = useUserStore()

// 查询竞赛 0/4
export function postAdminCompetition(status) {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/competition/admin/get',
            method: 'post',
            data: {
                status: status
            },
            params: {
                current: 1,
                size: 20
            }
        })
    } else {
        return 0
    }

}

// 查询paper 0/4
export function postPaperAdmin(status) {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/Paper/admin/search'+'?current='+1+'&size='+20,
            method: 'post',
            data: {
                status: status,
            },
            headers: {}
        })
    } else {
        return 0
    }

}

// 查询请假 0/3
export function postAdminAbsence(status) {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/leave/request',
            method: 'post',
            data: {
                status: status
            },
            params: {
                current: 1,
                size: 20
            }
        })
    } else {
        return 0
    }


}
// ppEcharts
export function postPpST(status,type) {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/Paper/admin/search'+'?current='+1+'&size='+20,
            method: 'post',
            data: {
                status: status,
                type: type,
            },
            headers: {}
        })
    } else {
        return 0
    }


}

export function postCaST() {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/home/admin/getData',
            method: 'get',
        })
    } else {
        return 0
    }

}

export function postImgItem(formValue) {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/home/admin/addCarousel',
            method: 'post',
            data: formValue,
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    } else {
        return 0
    }

}

export function delectImgItem(id) {
    if (userStore.userRole.includes('ROLE_ADMIN')) {
        return request({
            url: '/home/admin',
            method: 'delete',
            params: {
                carouselId: id
            }
        })
    } else {
        return 0
    }

}


